package pre.lxm.demo.drawable;


import android.graphics.drawable.GradientDrawable;

public class ShapeBackground {

    private static GradientDrawable mGradientDrawable;

    public static class ShapeBuilder {
        private int strokeWidth;
        private int strokeColor;
        private float dashWidth;
        private float dashGap;

        private int color;
        private int shape;


        //RECTANGLE
        private float topLeftRadius;
        private float topRightRadius;
        private float bottomLeftRadius;
        private float bottomRightRadius;

        public ShapeBuilder() {
        }

        public int getStrokeWidth() {
            return strokeWidth;
        }

        public ShapeBuilder setStrokeWidth(int strokeWidth) {
            this.strokeWidth = strokeWidth;
            return this;
        }

        public int getStrokeColor() {
            return strokeColor;
        }

        public ShapeBuilder setStrokeColor(int strokeColor) {
            this.strokeColor = strokeColor;
            return this;
        }

        public float getDashWidth() {
            return dashWidth;
        }

        public ShapeBuilder setDashWidth(float dashWidth) {
            this.dashWidth = dashWidth;
            return this;
        }

        public float getDashGap() {
            return dashGap;
        }

        public ShapeBuilder setDashGap(float dashGap) {
            this.dashGap = dashGap;
            return this;
        }

        public int getColor() {
            return color;
        }

        public ShapeBuilder setColor(int color) {
            this.color = color;
            return this;
        }

        public int getShape() {
            return shape;
        }

        public ShapeBuilder setShape(int shape) {
            this.shape = shape;
            return this;
        }

        public float getTopLeftRadius() {
            return topLeftRadius;
        }

        public ShapeBuilder setTopLeftRadius(float topLeftRadius) {
            this.topLeftRadius = topLeftRadius;
            return this;
        }

        public float getTopRightRadius() {
            return topRightRadius;
        }

        public ShapeBuilder setTopRightRadius(float topRightRadius) {
            this.topRightRadius = topRightRadius;
            return this;
        }

        public float getBottomLeftRadius() {
            return bottomLeftRadius;
        }

        public ShapeBuilder setBottomLeftRadius(float bottomLeftRadius) {
            this.bottomLeftRadius = bottomLeftRadius;
            return this;
        }

        public float getBottomRightRadius() {
            return bottomRightRadius;
        }

        public ShapeBuilder setBottomRightRadius(float bottomRightRadius) {
            this.bottomRightRadius = bottomRightRadius;
            return this;
        }

        public GradientDrawable build() {
            mGradientDrawable = new GradientDrawable();
            mGradientDrawable.setColor(color);
            mGradientDrawable.setStroke(strokeWidth, strokeColor, dashWidth, dashGap);
            mGradientDrawable.setShape(shape);
            mGradientDrawable.setCornerRadii(new float[]{topLeftRadius, topLeftRadius, topRightRadius,
                    topRightRadius, bottomRightRadius, bottomRightRadius, bottomLeftRadius,
                    bottomLeftRadius});
            return mGradientDrawable;
        }
    }
}
